<?php
require_once 'CMS/Util.php';
require_once 'CMS/Mvc/BaseController.php';
require_once 'CMS/Mvc/BaseUserController.php';
require_once 'CMS/UserCommon.php';

//Người tạo	: Hồ Nhật Tân - Team 1
//Module 	: Contact
//Chức năng	: Tạo trang gửi mail liên hệ
 
class ContactForm_ContactController extends BaseUserController{

	public function init(){
		parent::init();
	}

	//indexAction thực hiện chức năng gửi mail liên hệ
	public function indexAction(){
		
		//Start------Khởi tạo mã captcha
		$captcha = new Zend_Captcha_Image();
		$captcha	->setTimeout('300')
					->setWordLen('6')
					->setHeight('50')
					->setWidth('160')
					->setImgDir(APPLICATION_PATH . '/../public/captcha/images/')
					->setImgUrl('/captcha/images/')
					->setSuffix('.jpg')
					->setFont(APPLICATION_PATH . '/../public/captcha/font/jkasperville.ttf')
					->setFontSize('30')
					->setLineNoiseLevel('5')
					->setDotNoiseLevel('50')
					->setExpiration('1')
					->setGcFreq('1');
		$captcha->generate();
		$this->view->captcha = $captcha->render($this->view); 
		$this->view->captchaID = $captcha->getId();
		//End--------Khởi tạo mã captcha
		
		//Start------Đưa chuỗi captcha vào session
		$captchaSession = new Zend_Session_Namespace('Zend_Captcha_' . $captcha->getId());
		$captchaSession->word = $captcha->getWord();
		//End--------Đưa chuỗi captcha vào session
		
		//Start------Đổi catcha mới
    	if(count($_GET) && isset($_GET["captcha"]))
		{
			//Start------Tạo mã captcha mới
			$captchaNew = $captcha->render($this->view); 
			$captchaID = $captcha->getId();
			//End--------Tạo mã captcha mới
			
			//Start------Đưa chuỗi captcha vào session
			$captchaSession = new Zend_Session_Namespace('Zend_Captcha_' . $captcha->getId());
			$captchaSession->word = $captcha->getWord();
			//End--------Đưa chuỗi captcha vào session
			
			$this->_helper->json($captchaID);
			echo "abc";
			exit();
		}
		//End--------Đổi catcha mới
		
	}
	
}
?>